//
//  UIBarButtonItem+Exten.swift
//  up_learnWB
//
//  Created by Mac on 16/10/21.
//  Copyright © 2016年 www.ZXZ123.com. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    /// 自定义nav的item 展示文字
    ///
    /// - parameter title:    文字
    /// - parameter fontSize: 字体大小
    /// - parameter target:   调用
    /// - parameter action:   具体相应方法
    ///
    convenience init(title:String, fontSize:CGFloat = 16, target: Any?, action: Selector, isBack:Bool = false) {
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
        if isBack {
            let imageName = "navigationbar_back_withtext"

            btn.setImage(UIImage(named: imageName), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)

            btn.sizeToFit()
        }

        btn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        self.init(customView:btn)
    }


    
}
